package models;

public final class Handy {
    private Card [] hand;
    private int iloscKart;
    
    public Handy(Card [] added){
        iloscKart = 5;
        hand = new Card[iloscKart];
        System.arraycopy(added, 0, hand, 0, 5);
        sortHandy();
    }
    
    private void sortHandy(){
        for(int i = 0; i < iloscKart; ++i){
            for(int j = i + 1; j < iloscKart; ++j){
                if(hand[i].getWartosc() > hand[j].getWartosc()){
                    Card tmp = hand[i];
                    hand[i] = hand[j];
                    hand[j] = tmp;
                }
            }
        }
    }
    public boolean show(){
        for(int i = 0; i < 5; ++i){
            System.out.print("\"" + hand[i].toString() + "\", ");
        }
        return true;
    }

    public void exchange(int indeks, Card wymieniona){
        hand[indeks] = wymieniona;
        sortHandy();
        
    }
    
    public Card getCard(int indeks){
        return hand[indeks];
    }
    
    public int getWartosc(int indeks){
        return hand[indeks].getWartosc();
    }
    
    public String getKolor(int indeks){
        return hand[indeks].getKolor();
    }
    
    public String getFigura(int indeks){
        return hand[indeks].getFigura();
    }
    
    public Card [] getCards(){
        return hand;
    }
    
}
